package Day13.IO.zIFuLiu;

import javax.imageio.IIOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

public class ImgDemo1 {

    public static void main(String[] args) throws IOException {
//创建字节输入流对象，关联加密的图片
        FileInputStream fi = new FileInputStream("D:\\jiangnan1.jpg");
        //创建一个容器，用来存储读取到的字节
        ArrayList<Integer> list = new ArrayList<>();


        int i;
        while((i = fi.read())!=-1){

            list.add(i);
        }
        fi.close();

        FileOutputStream fo = new FileOutputStream("D:\\jiangnan1.jpg");
        //遍历集合，从集合中取出字节并写出
        for (Integer integer : list) {
            fo.write(integer ^ 2);
        }

        fo.close();
    }
}
